package com.zlx.store.goods.controller;

import com.zlx.store.common.results.HttpResp;
import com.zlx.store.common.constant.RespCode;
import com.zlx.store.domain.doc.GoodsDoc;
import com.zlx.store.domain.doc.GoodsSearch;
import com.zlx.store.goods.service.GoodDocService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.Date;
import java.util.HashMap;

@Api("tags=搜索接口类")
@RestController
@RequestMapping("/api/goodsDoc")
public class GoodsDocController {
    @Autowired
    GoodDocService goodDocService;
    @RequestMapping("add")
    public int add() throws IOException {
        goodDocService.update();
        return 1;
    }
    @GetMapping("search")
    public HttpResp search(@ModelAttribute GoodsSearch goodsSearch) throws IOException {
        HashMap result=goodDocService.search(goodsSearch.getKeyword(),goodsSearch.getOrder(),goodsSearch.getStore(),goodsSearch.getCategory(),goodsSearch.getPageNum(),goodsSearch.getPageSize());
        return HttpResp.httpResp(RespCode.ITEM_OPERATION_SUCCESS,result,new Date());
    }
}
